<template>
	<view>
		<view class="main">
			<view v-if="lists && lists.length > 0" class="lists">
				<view class="items" v-for="(item, index) in lists" :key="index" @click="toDetail(item)">
					<view class="left">
						<view class="date">
							<text>{{item.day}}</text>
						</view>
						<view class="totals">
							<text>交易总额：</text>
							<text>{{item.total}}</text>
						</view>
					</view>
					<view class="right">
						<u-icon name="arrow-right" color="#c8c9cc" size="26"></u-icon>
					</view>
				</view>
			</view>
			<u-empty class="policy_box" v-else mode="list" icon="/static/Empty/data_null.png"></u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				agentId: '',
				productId: '',
				month: '',
				lists: []
			}
		},
		onLoad(e) {
			this.month = e.month
			this.agentId = e.agentId
			this.productId = e.productId
			this.loadData()
		},
		methods: {
			// 加载数据
			async loadData() {
				uni.showLoading({
					title: '加载中'
				});
				const {
					data: res
				} = await this.$myHttp({
					url: 'v1/getHzyTradeTotalMonth',
					data: {
						agentId: this.agentId,
						productId: this.productId,
						month: this.month
					}
				});
				uni.hideLoading()
				if (res.code == 200) {
					this.lists = res.data
				}
			},
			// 详情
			toDetail(item) {
				if (this.productId != '') {
					uni.navigateTo({
						url: '/pages/hzy/trade/detail?day=' + item.day + '&agentId=' + item.main_id + '&productId=' + item.product_id
					})
				} else {
					uni.navigateTo({
						url: '/pages/hzy/trade/detail?day=' + item.day + '&agentId=' + item.main_id + '&productId=' + this.productId
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		.lists {
			padding: 0 30rpx;
			background-color: #ffffff;
			.items {
				padding: 30rpx 0;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1px solid #f4f4f5;
				font-size: 24rpx;
				
				.date {
					font-weight: bold;
					font-size: 28rpx;
					padding-bottom: 10rpx;
				}
				
				.totals {
					color: #909399;
				}
			}
		}
	}
</style>